package server.handler.userHandler;

import com.alibaba.fastjson.JSONObject;
import common.EnvelopeMessage;
import server.handler.SimpleHandler;
import server.session.Session;
import server.session.SessionManager;


public class UserLogoutHandler implements SimpleHandler {
    @Override
    public void handle(EnvelopeMessage msg, Session session) {
        JSONObject body = msg.getBody();
        Integer userId = body.getInteger("userId");
        SessionManager.remove(userId);
        System.out.println("用户 " + userId + " 已登出");
        session.close();
    }
}
